﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MantenedorRepartidor.aspx.cs" Inherits="AppPizza.MantenedorRepartidor" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Página sin título</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="GridView1" runat="server" 
            AutoGenerateColumns="False" CellPadding="4" DataKeyNames="id_repartidor" 
            DataSourceID="SqlDataSourceRepartidores" ForeColor="#333333" 
            GridLines="None">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="id_repartidor" HeaderText="id_repartidor" 
                    InsertVisible="False" ReadOnly="True" SortExpression="id_repartidor" />
                <asp:BoundField DataField="nombre" HeaderText="nombre" 
                    SortExpression="nombre" />
                <asp:BoundField DataField="tipo_vehiculo" HeaderText="tipo_vehiculo" 
                    SortExpression="tipo_vehiculo" />
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSourceRepartidores" runat="server" 
            ConnectionString="<%$ ConnectionStrings:pizzeriaConnectionString2 %>" 
            DeleteCommand="DELETE FROM [repartidor] WHERE [ID_Repartidor] = @ID_Repartidor" 
            InsertCommand="INSERT INTO [repartidor] ([ID_Repartidor], [Nombre], [ID_Vehiculo]) VALUES (?, ?, ?)" 
            ProviderName="<%$ ConnectionStrings:pizzeriaConnectionString2.ProviderName %>" 
            SelectCommand="SELECT id_repartidor,nombre,tipo_vehiculo FROM [repartidor] INNER JOIN [vehiculos] ON repartidor.Id_vehiculo = Vehiculos.Id_Vehiculo" 
            
            UpdateCommand="UPDATE [repartidor] SET [Nombre] = @Nombre WHERE [ID_Repartidor] = @ID_Repartidor">
            <DeleteParameters>
                <asp:Parameter Name="ID_Repartidor" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Nombre" Type="String" />
                <asp:Parameter Name="ID_Vehiculo" Type="Int32" />
                <asp:Parameter Name="ID_Repartidor" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ID_Repartidor" Type="Int32" />
                <asp:Parameter Name="Nombre" Type="String" />
                <asp:Parameter Name="ID_Vehiculo" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
    
        <asp:SqlDataSource ID="SqlDataSourceRepas" runat="server" 
            ConflictDetection="CompareAllValues" 
            ConnectionString="<%$ ConnectionStrings:pizzeriaConnectionString2 %>" 
            DeleteCommand="DELETE FROM [repartidor] WHERE [ID_Repartidor] = ? AND [Nombre] = ? AND [ID_Vehiculo] = ? AND (([Email] = ?) OR ([Email] IS NULL AND ? IS NULL))" 
            InsertCommand="INSERT INTO [repartidor] ([ID_Repartidor], [Nombre], [ID_Vehiculo], [Email]) VALUES (?, ?, ?, ?)" 
            OldValuesParameterFormatString="original_{0}" 
            ProviderName="<%$ ConnectionStrings:pizzeriaConnectionString2.ProviderName %>" 
            SelectCommand="SELECT * FROM [repartidor]" 
            UpdateCommand="UPDATE [repartidor] SET [Nombre] = ?, [ID_Vehiculo] = ?, [Email] = ? WHERE [ID_Repartidor] = ? AND [Nombre] = ? AND [ID_Vehiculo] = ? AND (([Email] = ?) OR ([Email] IS NULL AND ? IS NULL))">
            <DeleteParameters>
                <asp:Parameter Name="original_ID_Repartidor" Type="Int32" />
                <asp:Parameter Name="original_Nombre" Type="String" />
                <asp:Parameter Name="original_ID_Vehiculo" Type="Int32" />
                <asp:Parameter Name="original_Email" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Nombre" Type="String" />
                <asp:Parameter Name="ID_Vehiculo" Type="Int32" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="original_ID_Repartidor" Type="Int32" />
                <asp:Parameter Name="original_Nombre" Type="String" />
                <asp:Parameter Name="original_ID_Vehiculo" Type="Int32" />
                <asp:Parameter Name="original_Email" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ID_Repartidor" Type="Int32" />
                <asp:Parameter Name="Nombre" Type="String" />
                <asp:Parameter Name="ID_Vehiculo" Type="Int32" />
                <asp:Parameter Name="Email" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
        <br />
    
    </div>
    Ingresar nuevo repartidor<br />
    <asp:SqlDataSource ID="datasrcID_MAX" runat="server" 
        ConnectionString="<%$ ConnectionStrings:pizzeriaConnectionString2 %>" 
        onselecting="datasrcID_MAX_Selecting" 
        ProviderName="<%$ ConnectionStrings:pizzeriaConnectionString2.ProviderName %>" 
        SelectCommand="SELECT MAX(id_repartidor) from repartidor">
    </asp:SqlDataSource>
    <asp:Label ID="Label3" runat="server" Text="ID:"></asp:Label>
    <asp:DropDownList ID="ddlID" runat="server" DataSourceID="datasrcID_MAX" 
        DataTextField="MAX(id_repartidor)" DataValueField="MAX(id_repartidor)">
    </asp:DropDownList>
    <br />
    <asp:Label ID="Label1" runat="server" Text="Nombre:"></asp:Label>
    <asp:TextBox ID="txtNombreRep" runat="server"></asp:TextBox>
    <br />
    Tipo de vehiculo:
    <asp:DropDownList ID="ddlTipoDeVehiculoRep" runat="server" 
        DataSourceID="SqlDataSourceVehiculos" DataTextField="Tipo_Vehiculo" 
        DataValueField="ID_Vehiculo">
    </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSourceVehiculos" runat="server" 
        ConnectionString="<%$ ConnectionStrings:pizzeriaConnectionString2 %>" 
        ProviderName="<%$ ConnectionStrings:pizzeriaConnectionString2.ProviderName %>" 
        SelectCommand="SELECT * FROM [vehiculos]"></asp:SqlDataSource>
    <asp:Label ID="Label2" runat="server" Text="Email:"></asp:Label>
    <asp:TextBox ID="txtEmailRep" runat="server"></asp:TextBox>
    <br />
    <asp:Button ID="btnIngresarRep" runat="server" onclick="btnIngresarRep_Click" 
        Text="Ingresar" />
    <br />
    <br />
    <asp:Label ID="lblEstado" runat="server"></asp:Label>
    <br />
    <br />
    </form>
</body>
</html>
